//
//  BelowPayTableViewCell.m
//  cityStar
//
//  Created by Hancong on 14/12/25.
//  Copyright (c) 2014年 tiny. All rights reserved.
//

#import "BelowPayTableViewCell.h"

@implementation BelowPayTableViewCell

+(CGFloat)heightOfTableCell
{
    return 361;
}
- (IBAction)zhifu_Action:(id)sender {
    [self.fieldPayType becomeFirstResponder];
}

- (IBAction)scoreJump:(id)sender {
    [self.duihuanTextFiled resignFirstResponder];
    if ([self.delegate respondsToSelector:@selector(belowScoreButtonBeTouched)] == YES) {
        [self.delegate belowScoreButtonBeTouched];
    }
}

- (IBAction)daijinquanJump:(id)sender {
    [self.duihuanTextFiled resignFirstResponder];
    if ([self.delegate respondsToSelector:@selector(belowDaijinquanButtonBeTouched)] == YES) {
        [self.delegate belowDaijinquanButtonBeTouched];
    }
}

- (void)awakeFromNib {
    self.duihuanTextFiled.returnKeyType = UIReturnKeyDone;
    self.duihuanTextFiled.delegate = self;
    self.pickerView = [[UIPickerView alloc]init];
    self.pickerView.delegate = self;
    self.fieldPayType.inputView = self.pickerView;
    
    UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
    [topView setBarStyle:UIBarStyleDefault];
    
    UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    
    UIBarButtonItem * doneButton = [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
    
    NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneButton,nil];
    
    [topView setItems:buttonsArray];
    [self.fieldPayType setInputAccessoryView:topView];
}

-(void)dismissKeyBoard
{
    [self.fieldPayType resignFirstResponder];
    
}


#pragma mark - pickerViewDelegate
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 1;
}

-(NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    return 3;
}

-(NSString*) pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    if (row == 0) {
        return @"银联支付";
    }else if (row == 1){
        return @"支付宝快捷支付";
    }else
    {
        return @"账户余额支付";
    }
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    if (row == 0) {
        self.fieldPayType.text = @"银联支付";
    }else if (row == 1){
        self.fieldPayType.text = @"支付宝快捷支付";
    }else
    {
        self.fieldPayType.text = @"账户余额支付";
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
